home *** CD-ROM | disk | FTP | other *** search
-
-
- ;------Cleanup-----------------------------------------
- ;
- ; Cleanup method of the object.
- ;
- Pro AS2PI_tpl::Cleanup
-
- ;Save widget geometry and display parameters
- self->Settings, /Save
-
- ;Free pointers (add new pointers here)
- Ptr_Free, self.lang
-
-
- End
- ;------------------------------------------------------
-
-
-
- ;------Settings-----------------------------------------------------------------
- ;
- ; Method to save and restore basic object settings.
- ; ->Settings, inis, /Save - pass back settings via inis
- ; ->Settings, inis, /Restore - store external settings
- ; ->Settings, /Save - saves settings to default file (on destruction of self)
- ; ->Settings, /Restore - restores settings from default file (on initialization of self)
- ;
- Pro AS2PI_tpl::Settings, inis, Save = Save, Restore = Restore
-
- ;If inis is present, AviStack wants to save or store project data
- NoSaveData = Arg_Present(inis) EQ 0
-
- ;Dummy data structure
- inis0 = {id: 'AS2PI_tpl', $
- color: 0, $
- fit: 0, $
- xOffset: 0L, $
- yOffset: 0L}
-
- ;Tag names of the structure for comparison (which are present in the restored data?)
- Tags0 = Tag_Names(inis0)
-
- ;Save settings (if inis Argument is present, inis will be passed back)
- If Keyword_Set(Save) Then Begin
-
- inis0.color = self.color
- inis0.fit = self.fit
-
- If Widget_Info(self.tlb, /Valid_ID) Then Begin
- geo = Widget_Info(self.tlb, /Geometry)
- inis0.xOffset = geo.xOffset
- inis0.yOffset = geo.yOffset
- EndIf Else Begin
- inis0.xOffset = self.xOffset
- inis0.yOffset = self.yOffset
- EndElse
-
- inis = inis0
-
- ;Store only if no settings pass back is desired
- If NoSaveData Then Save, File = self.ini, inis
-
- EndIf
-
- ;Load settings (either implement settings passed on by inis or restore file)
- If Keyword_Set(Restore) Then Begin
-
- ;Check settings file. Does it contain the "inis" structure?
- If NoSaveData Then Begin
- If ~ReadSaveFile(self.ini, inis = inis) Then inis = inis0
- EndIf
-
- Tags = Tag_Names(inis)
-
- If Total(Tags EQ 'COLOR') Then self.color = inis.color Else self.color = inis0.color
- If Total(Tags EQ 'FIT') Then self.fit = inis.fit Else self.fit = inis0.fit
- If Total(Tags EQ 'XOFFSET') Then self.xOffset = inis.xOffset Else self.xOffset = inis0.xOffset
- If Total(Tags EQ 'YOFFSET') Then self.yOffset = inis.yOffset Else self.yOffset = inis0.yOffset
-
- EndIf
-
- End
- ;--------------------------------------------------------------------------------------------------------------
-
-
-
- ;----ClearData----------------------------
- ;
- ; Method resets pointers to free memory
- ; Use this methd when you unmap the TLB
- ;
-
- Pro AS2PI_tpl::ClearData
-
- End
- ;-----------------------------------------
-
-
-
-
- ;----Finished--------------------------------------------------------------------
- ;
- ; Method to notify AviStack2 that processing is finished.
- ; Successfully: ok=1 else ok = 0
- ;
-
- Pro AS2PI_tpl::Finished, ok
-
- ;Send event to group leader
- Widget_Control, self.Group_Leader, Send_Event = {Processing, 0L, 0L, 0L, ok, 2}
-
- End
- ;--------------------------------------------------------------------------------
-
-
- ;----UpdateObject--------------------------------------------------------------------------------------
- ;
- ;
- ;
-
- Pro AS2PI_tpl::UpdateObject
-
- ;Obtain AviStack2's object reference (stored in uValue of its TLB)
- Widget_Control, self.Group_Leader, Get_uValue = AviStack2
-
- ;Get channels flag (0: gray scale, 1: RGB, 2,3,4: R,G,B (only one channel processed, gray scale))
- self.channels = AviStack2->GetProperty(/Channels) * AviStack2->GetProperty(/aChan)
- ;Maximum pixel value (for scaling the data for correct display).
- self.maxval = AviStack2->GetProperty(/maxval)
-
- self.wx = AviStack2->GetProperty(/dx_)
- self.wy = AviStack2->GetProperty(/dy_)
-
- ;---- Add paremters here that you want to update ------------------------
-
-
-
-
- End
- ;------------------------------------------------------------------------------------------------------
-
-
-
-
-
- ;----Map----------------------------------------------------------------------------------------
- ;
- ; Method to map the GUI (managed by AviStack2)
- ;
-
- Pro AS2PI_tpl::Map, Auto = Auto, Preset = Preset, Close = Close, WorkPath = WorkPath
-
-
- If Keyword_Set(Close) Then Begin
-
- Widget_Control, self.tlb, Map = 0
-
- ;Clear the pointer data to save memory (optional)
- self->ClearData
-
- EndIf Else Begin
-
- ;Obtain the most recent parameters and data from AviStack2
- self->UpdateObject
-
- ;Update workpath when TLB is mapped (optional)
- self.workPath = WorkPath
-
- ;Send help text to help label in main GUI (optional)
- Widget_Control, self.Group_Leader, Get_uValue = AviStack2
- AviStack2->Event, {Info, 0L, 0L, 0L, (*self.lang).info}
-
-
- ;---- Update of TLB ----------------------------------------
- ;
- ; Add your code here to update the TLB
- ;
-
-
-
- ;-----------------------------------------------------------
-
- ;Display data (optional)
- self->ShowFrame
-
- ;Update the widgets of your TLB (optional)
- self->UpdateWidgets
-
- ;Map the TLB
- Widget_Control, self.tlb, Map = 1
-
- EndElse
-
- End
- ;-------------------------------------------------------------------------------------------------
-
-
-
-
-
- ;----ShowFrame-------------------------------------------------------------------
- ;
- ; Method shows the current frame and draws the alignment points
- ;
-
- Pro AS2PI_tpl::ShowFrame
-
- Widget_Control, /Hourglass
-
- ;---- Add you code here ----------------------
-
-
-
-
- ;---------------------------------------------
-
- Widget_Control, Hourglass = 0
-
- End
- ;---------------------------------------------------------------------------------------------------
-
-
-
-
-
-
- ;-----Event-----------------------------------------------------------------------------------------
- ;
- ; Method to process the events
- ;
-
- Pro AS2PI_tpl_Event, ev
-
- Widget_Control, ev.top, Get_uValue = self
- self->Event, ev
-
- End
-
-
- Pro AS2PI_tpl::Event, ev
-
- Widget_Control, ev.id, Get_uValue = info
-
- Case info.type Of
-
- 'Cancel': self->Finished, 0
-
- 'OK': self->Finished, 1
-
- Else:
-
- EndCase
-
-
- End
- ;----------------------------------------------------------------------------------------------------
-
-
-
-
-
-
- ;----UpdateWidgets--------------------------------------------------------------------------------------------------
- ;
- ; Method to update the widgets of your TLB
- ;
-
- Pro AS2PI_tpl::UpdateWidgets
-
- ;---- Add your code here --------------
-
- End
- ;-------------------------------------------------------------------------------------------------------------------
-
-
-
-
-
- ;----BuildGUI-----------------------------------------------------------------------------------------------------------
- ;
- ; Method builds the GUI of the object
- ;
- ; Keywords:
- ; Group_Leader: The group leader's widget ID (must be present)
- ;
-
- Pro AS2PI_tpl::BuildGUI, Group_Leader = Group_Leader
-
- ;Store the group leader's ID
- self.Group_Leader = Group_Leader
-
- ;Restore initial GUI geometry
- self->Settings, /Restore
-
- ;---- TLB definition ------------------------------------------------------------------------------------------
- ;
- ; Do not change this. The object reference is stored in the user value of the TLB.
- ; If you want to store your own user values, create a base widget as a child of the TLB and
- ; store it there.
- ;
-
- self.tlb = Widget_Base(Group_Leader = self.Group_Leader, xOffset = self.xOffset, yOffset = self.yOffset, $
- Map = 0, uValue = self, /Column, Tlb_Frame_Attr = 11, $
- /Floating, Title = (*self.lang).title, /Base_Align_Center)
-
-
-
- bdx = 200
-
- ;OK and cancel buttons
- ocBase = Widget_Base(self.tlb, /Row, /Grid_Layout, xPad = 0, yPad = 0)
- okButton = Widget_Button(ocBase, Value = (*self.lang).ok, uValue = {type: 'OK'}, xSize = bdx/2-2)
- caButton = Widget_Button(ocBase, Value = (*self.lang).cancel, uValue = {type: 'Cancel'}, xSize = bdx/2-2)
-
- ;---- Add your widgets here -----------------------------------------------------------------------------------
-
- ;The user value of your widgets must be a structure and contain at least the tag "Type" to identify
- ; the event in the event handler uValue = {Type: 'Name', ...}. See predefined widgets above.
-
-
- ;--------------------------------------------------------------------------------------------------------------
-
-
- Widget_Control, self.tlb, /Realize
-
- xManager, 'AS2PI_tpl', self.tlb, /No_Block
-
- End
- ;---------------------------------------------------------------------------------------------------------------
-
-
-
-
-
-
- ;----SetProperty---------------------------------------------------------------
- ;
- ; Method that allows AviStack2 to pass data to the object.
- ; fit: 100% or scaled display of the data
- ; fp: Conversion parameters to convert device to
- ; scaled coordinates for each fit mode [1, f]
- ; data: Movie frame data
- ;
-
- Pro AS2PI_tpl::SetProperty, fp = fp, $
- fit = fit, $
- color = color
-
-
- If N_Elements(fp) GT 0 Then self.fp = fp
- If N_Elements(fit) GT 0 Then self.fit = fit
- If N_Elements(color) GT 0 Then self.color = color
-
- End
- ;----------------------------------------------------------------------------------
-
-
-
-
-
- ;----GetProperty-----------------------------------------------------------------
- ;
- ; Method to access data of the object
- ;
-
- Function AS2PI_tpl::GetProperty, draw_events = draw_events, $
- wx = wx, $
- wy = wy, $
- fit = fit, $
- color = color, $
- title = title, $
- prog = prog
-
- ;---- Draw events ------------------------------------------
- ;
- ; Allows AviStack2 to check if the object is to receive
- ; draw events from the main display.
-
- If Keyword_Set(draw_events) Then Return, self.draw_events
-
-
- ;---- Frame display ----------------------------------------
- ;
- ; These parameters must all be accessible by AviStack2
- ; to ensure a proper display of data.
- ;
- ; wx, wy: The 100% dimensions of the displayed data
- ; fit: Use 100% or scaled display (managed by AviStack2)
- ; color: Color mode selected for the object (managed by AviStack2)
- ;
-
- If Keyword_Set(wx) Then Return, self.wx
- If Keyword_Set(wy) Then Return, self.wy
- If Keyword_Set(fit) Then Return, self.fit
- If Keyword_Set(color) Then Return, self.color
-
-
- ;---- Title ------------------------------------------
- ;
- ; Allows AviStack2 to obtain the plug-in's title
- ; Used as entry for the "Extras" menu.
- ;
-
- If Keyword_Set(title) Then Return, (*self.lang).title
-
-
- ;---- Progress flag-----------------------------
- If Keyword_Set(prog) Then Return, self.prog
-
- ;---- Frame data -------------------------------------
- ;
- ; Allows AviStack2 to display modified frame data
- ;
-
- End
- ;------------------------------------------------------------------------------
-
-
-
-
-
- ;----Init------------------------------------------------------------------------------------
- ;
- ; Method initializes the object
- ;
- ; Keywords (must all be present):
- ; setPath: The path (string) of the settings file (.ass)
- ; cLang: The string of the selected language (e.g. 'ENG' for English)
- ; LangDir: The path (string) where the language files are located
- ;
-
- Function AS2PI_tpl::Init, setPath = setPath, $
- cLang = cLang, $
- LangDir = LangDir
-
- ;---- Progress flag ------------------------------------
- ;
- ; Accessed by AviStack2 (::GetProperty)
- ; AS2 then knows when it is OK to map/use this object
- ;
-
- self.prog = 100
-
- ;---- Settings and language library paths -------------------------------
- ;
- ; Stores the paths to the settings file (.ass)
- ; and the language library file (.xml) and the language acronym.
- ;
-
- self.setPath = setPath
- self.langDir = langDir
- self.cLang = cLang
-
-
- ;---- Lnaguage data--------------------------------------------------------------------------
- ;
- ; You must create a XML language library for your object and its TLB.
- ;
-
- file = 'AS2PI_Tpl'
- clFile = LangDir + file + '_' + cLang + '.xml'
- ceFile = LangDir + file + '_ENG.xml'
- lFiles = File_Search(clFile, count = true)
- If true Then self.lang = Ptr_New(GetLng(lFiles)) Else self.lang = Ptr_New(GetLng(ceFile))
-
-
-
- ;---- Settings file name -------------------------------
- ;
- ; The name of the file where the initial settings
- ; of your object and its TLB are stored
- ;
-
- self.ini = setPath + file + '.ass'
-
-
- ;---- Init pointers -----------
- ;
- ; (add more pointers here if necessary)
- ;
-
-
-
- ;---- Draw events from main display -----------------------------------
- ;
- ; Object uses draw events (set to 1 if your object is to be able to
- ; receive draw events from the main display)
- ;
-
- self.draw_events = 0
-
- Return, 1
-
- End
- ;------------------------------------------------------------------------------------------------
-
-
-
-
-
- ;----Object definition--------------------------------------------------
- ;
- ; Add your own variables here.
- ; Add the IDs of the widgets you add to the TLB or use otherwise (only
- ; required of you want to update these widgets).
- ;
-
- Pro AS2PI_tpl__define
-
- void = {AS2PI_tpl, $
-
- setPath: '', $ ;Path to the settings file
- langDir: '', $ ;Path to the objects language library
- cLang: '', $ ;Language acronym
- workPath: '', $ ;Current work path (movie location)
-
- prog: 0L, $ ;Progress flag. Accessed by AviStack2 to know when the object is allowed to be mapped.
-
- ini: '', $ ;File Name: Settings data
- draw_events: 0, $ ;Flag: Receive draw events from main display
-
- tlb: 0L, $ ;Base ID: Top level base
- xOffset: 0L, $ ;Tlb geometry
- yOffset: 0L, $
-
- group_leader: 0L, $ ;The ID of the group leader
-
- color: 0L, $ ;Color mode flag (managed by AviStack2)
- fit: 0L, $ ;Frame fit mode (managed by AviStack2)
- fp: FltArr(2), $ ;Fitting parameters (managed by AviStack2)
- wx: 0L, $ ;100% x-size of a frame to be displayed
- wy: 0L, $ ;100% y-size of a frame to be displayed
-
- channels: 0, $ ;Channels flag
- maxval: 0d, $ ;Maximum pixel value
-
- lang: Ptr_new()}
-
- End